﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Login
{
    public partial class Login : Form
    {
        Model.userInfo m_userInfo = new Model.userInfo();
        BLL.userAccess b_userAccess = new BLL.userAccess();
        BLL.TCPComm b_TCPComm = new BLL.TCPComm();  

        public Login()
        {
            InitializeComponent();
        }

        private void butOpenComm_Click(object sender, EventArgs e)
        {            
            m_userInfo.userAccount = textBoxAccount.Text.Trim();
            m_userInfo.psw = textBoxPsw.Text.Trim();

            //调试，固定账号和密码
            m_userInfo.userAccount = "admin";
            m_userInfo.psw = "admin";
            if (b_userAccess.userLogin(m_userInfo) > 0)
            {                
                //MessageBox.Show("登录成功");
               // b_TCPComm.openComm(textBoxSerIp.Text.Trim());
                b_TCPComm.openComm("127.0.0.1","8000");
                MessageBox.Show(b_TCPComm.acceptedSocket.Connected.ToString());
            }
            else
            {
                MessageBox.Show("登录失败");
            }
        }

        private void butSendData_Click(object sender, EventArgs e)
        {
            b_TCPComm.sendData(textBoxSendData.Text);
        }

        private void butQuit_Click(object sender, EventArgs e)
        {
            b_TCPComm.closeSocket();
            Application.Exit();
        }        
    }
}
